package cbh.tool.convert;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * Created by hx-pc on 16-1-27.
 */
public class MapClass {

    public static List<MapBean> toClass(Map map) {
        List<MapBean> list = new ArrayList<>();
        Set<Map.Entry> set = map.entrySet();
        set.forEach(entry ->{
            list.add(new MapBean(entry.getKey(),entry.getValue()));
        });
        return list;
    }

    public static MapStringList toInsertStringList(Map map) {
        List keys = new ArrayList<>();
        List values = new ArrayList<>();
        Set<Map.Entry> set = map.entrySet();
        set.forEach(entry ->{
            keys.add(entry.getKey());
            values.add(entry.getValue());
        });
        return new MapStringList(keys,values);
    }

    public static MapStringList toUpdateClass(Map conditionMap,Map contentsMap) {
        List<MapBean> conditions = new ArrayList<>();
        List<MapBean> contents = new ArrayList<>();
        Set<Map.Entry> conditionSet = conditionMap.entrySet();
        Set<Map.Entry> contentSet = contentsMap.entrySet();
        conditionSet.forEach(entry ->{
            conditions.add(new MapBean(entry.getKey(),entry.getValue()));
        });
        contentSet.forEach(entry ->{
            contents.add(new MapBean(entry.getKey(),entry.getValue()));
        });
        return new MapStringList(conditions,contents);
    }
}
